import { fetchEmployeeListAPI } from '@/api/system/employee'

const actions = {
  /* 发送请求获取员工列表的action */
  async fetchEmployeeList(context, pageParams) {
    const { data } = await fetchEmployeeListAPI(pageParams)
    context.commit('updateEmployeeList', data)
  }
}
const mutations = {
  /* 更新员工列表的mutation */
  updateEmployeeList(state, employeeListInfo) {
    state.employeeListInfo = employeeListInfo
  }
}
const state = () => {
  return {
    employeeListInfo: {}
  }
}

const getters = {
  employeeList(state) {
    return state.employeeListInfo.rows
  },
  total(state) {
    return state.employeeListInfo.total
  }
}

export default {
  actions,
  mutations,
  state,
  getters,
  namespaced: true
}
